package com.hb.qlg.system.controller;

import com.hb.common.base.Result;
import com.hb.qlg.system.entity.SysUser;
import com.hb.qlg.system.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/*
* @Description: SysUserController
* @Author: YangTing
* @Date: 2025/6/25 上午11:35
**/
@RestController
@RequestMapping("/system/users")
public class SysUserController {

    @Autowired
    private SysUserService userService;

    /**
     * 获取用户列表
     */
    @GetMapping("list")
    public Result<?> list() {
        return Result.success(userService.list());
    }

    /**
     * 添加新用户
     */
    @PostMapping("/add")
    public Result<?> add(@RequestBody SysUser user) {
        return Result.success(userService.save(user));
    }

    /**
     * 更新用户信息
     */
    @PutMapping("/update")
    public Result<?> update(@RequestBody SysUser user) {
        return Result.success(userService.updateById(user));
    }

    /**
     * 删除指定用户
     */
    @DeleteMapping("/{id}")
    public Result<?> delete(@PathVariable Long id) {
        return Result.success(userService.removeById(id));
    }
}
